<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<title>我的活动</title>
<%@include file="/common/wxCommon.jspf"%>
<style>
.weui_cell:before {
	left: 0px;
}
a {
	color: black;
}
</style>
<body ontouchstart>
	<div class="weui_tab" id='page-infinite-navbar'>
		<div class="weui_navbar">
			<a href='#tab1' class="weui_navbar_item weui_bar_item_on">进行中 </a>
			<a href='#tab2' class="weui_navbar_item">已完成</a>
		</div>
		<div class="weui_tab_bd">
			<div id="tab1" class="weui_tab_bd_item weui_tab_bd_item_active" tab="pre">
				<div class="content">
				</div>
			</div>
			<div id="tab2" class="weui_tab_bd_item" tab="done">
				<div class="content">
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
	$(function() {
	    $("#tab1, #tab2").infinite().on("infinite", function() {
	        var self = this;
	        if (self.loading) return;
	        self.loading = true;
	        self.pageNow = self.pageNow ?  self.pageNow : 1
	        $.getJSON(rootPath + '/weixin/user/party/findByPage.shtml', { 'pageNow' : self.pageNow, 'pageSize' : 10, 'type' : $(self).attr("tab") }, function(result) {
				$.each(result.records, function(i, e) {
					var imgStatus;
					if (e.status == 4) {
						imgStatus = '<img class="party-img" src="${ctx }/images/weixin/comment' + (e.commentStatus == 0 ? "" : "ed") + '.png" comment="' + e.id + '"/>';
					} else {
						imgStatus = '<img class="party-img" src="${ctx }/images/weixin/party' + (e.status == 1 ? "Pre" : "In") + '.png" />';
					}
					$(self).find(".content").append('<div class="weui_cell weui_cells_access">' +
							'<div class="weui_cell_bd weui_cell_primary" onclick="partyDetail(' + e.id + ')">' +
							'<p>' + e.subject + '</p>' +
							'<label class="cell-tips">' + (new Date(e.startTime).format("yyyy-MM-dd hh:mm")) +
							'&nbsp;&nbsp;' + e.orgName + '</label>' +
							'</div><div class="weui_cell_ft">' + imgStatus +
							'	<img class="party-img" src="${ctx }/images/weixin/qrcodeOn.png" pic="' + e.qrCode + '"/>' +
							'</div></div>');
				});
				self.pageNow += 1;
				self.loading = false;
				if (self.pageNow > result.pageCount) {
					$(self).destroyInfinite();
				}
			});
	    });
	    $("#tab1,#tab2").trigger("infinite");//首次加载
	    
	    $(document).on("click", "img", function() {
	    	if ($(this).attr("pic")) {
	    		wx.previewImage({current: $(this).attr("pic"), urls: [$(this).attr("pic")]});
	    	} else if($(this).attr("comment")) {
		    	location.href = "${ctx}/weixin/user/party/comment.shtml?partyId=" + $(this).attr("comment");
	    	}
	    });
	});
	
	function partyDetail(id) {
		location.href = "${ctx}/weixin/user/party/detail.shtml?partyId=" + id;
	}
	</script>
</body>
</html>